home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / GENetReleaseƒ / GELibHeaders / DispCtrl.h < prev    next >
Text File  |  1994-03-07  |  7KB  |  278 lines

  1. /*
  2.     DispCtrl.h
  3.     
  4.     Display Controller routines for Graphic Elements
  5.     
  6.     Copyright 1994 by Al Evans. All rights reserved.
  7.     
  8.     Release version 1.0b1
  9.     
  10.     3/7/94
  11.  
  12. */
  13.  
  14. #ifndef DISPCTRL
  15. #define DISPCTRL
  16.  
  17. #include "Defs.h"
  18.  
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24.  
  25. //Creation of new GEWorld
  26.  
  27. /*
  28.     Returns pointer to a new GEWorld. This world covers the area of worldWindow
  29.     specified by animationRect (in window coordinates).  If it is not nil, worldColors
  30.     must be a handle to a color table appropriate for an 8-bit depth.
  31.     
  32. */
  33.  
  34. GEWorldPtr NewGEWorld(CWindowPtr worldWindow, Rect *worldRect, CTabHandle worldColors);
  35.  
  36.  
  37. //Destruction of a GEWorld
  38.  
  39. /*
  40.     Disposes of a world and everything in it EXCEPT! memory allocated by application
  41.     and stored in GrafElPtrs
  42. */
  43.  
  44. void DisposeGEWorld(GEWorldPtr world);
  45.  
  46.  
  47. //Management of a GEWorld
  48.  
  49. /*
  50.     Set default loader function for world.  If no loader is specified when a new
  51.     Graphic Element is created, this function is used.
  52.     
  53.     In a newly-created world, this loader function is one which creates an offscreen
  54.     GWorld and loads one or more PICTS from an open resource fork into it.
  55. */
  56.  
  57. void SetDefaultLoadFunc(GEWorldPtr world, GraphicLoadFunc loader);
  58.  
  59. /*
  60.  
  61.     Activate or deactivate an individual world
  62. */
  63.  
  64. void ActivateWorld(GEWorldPtr world, Boolean turnItOn);
  65.  
  66. /*
  67.     Get and set projection rate
  68.     These are NOT very useful, but MAY improve performance in some situations on
  69.     slower machines.
  70. */
  71.  
  72. void SetProjectionRate(GEWorldPtr world, short newMSPerFrame);
  73.  
  74. short GetProjectionRate(GEWorldPtr world);
  75.  
  76. /*
  77.     Control GEWorld's timer
  78. */
  79.  
  80. void StartGETimer(GEWorldPtr world);
  81.  
  82. void StopGETimer(GEWorldPtr world);
  83.  
  84.  
  85. //Returns current time in world
  86. unsigned long CurrentGETime(GEWorldPtr world);
  87.  
  88. /*    Set the number of timer milliseconds that pass per "real"
  89.     millisecond. newRate is treated as a fixed-point number,
  90.     with a two-byte positive integer and a two byte fraction,
  91.     such that a value of 00010000 will give a 1-to-1
  92.     correspondence between Graphic Elements "milliseconds"
  93.     and real milliseconds.
  94. */
  95.  
  96. void SetGETimerRate(GEWorldPtr world, unsigned long newRate);
  97.  
  98. //Returns current "rate" of timer in world
  99. unsigned long GetGETimerRate(GEWorldPtr world);
  100.  
  101. /*
  102.     Manipulate world coordinate system;
  103. */
  104.  
  105. /*
  106.     GetGEWorldFocus and SetGEWorldFocus should be used to "bracket" calls to
  107.     FocusOnGEWorld, in order to save and restore the previous focus.
  108. */
  109.  
  110. void GetGEWorldFocus(GEWorldPtr world, Point *currFocus);
  111. void SetGEWorldFocus(GEWorldPtr world, Point newFocus);
  112.  
  113. /*
  114.     Sets focus, i.e. coordinate system, to that of world
  115. */
  116.  
  117. void FocusOnGEWorld(GEWorldPtr world);
  118.  
  119. /*
  120.     Move an entire GEWorld relative to its window
  121. */
  122.  
  123. void MoveGEWorld(GEWorldPtr world, short dh, short dv);
  124. void MoveGEWorldTo(GEWorldPtr world, short h, short v);
  125.  
  126. /*
  127.     Generate a frame showing the world in its current state and display it on the screen.
  128.     Should be called frequently from application program, for example once each time
  129.     through the main event loop.
  130.     
  131.     If invalidate is true, the entire world is redrawn. Otherwise, only the changed
  132.     portions of world are updated.
  133. */
  134.  
  135. void DoWorldUpdate(GEWorldPtr world, Boolean invalidate);
  136.  
  137. /*
  138.     Call from event handler when mouse down in the window containing world.
  139.     Returns true if mouseDown was handled by a sensor, false otherwise.
  140. */
  141.  
  142. Boolean MouseDownInSensor(GEWorldPtr world, Point gMousePt);
  143.  
  144.  
  145. //Services provided by Display Controller for Graphic Elements
  146.  
  147. //Creation and destruction
  148.  
  149. /* 
  150.     Low-level element creation. This function allocates an element, calls its
  151.     GraphicLoadFunc proc (if any), and links it into the world. In itself, it 
  152.     initializes only the fields element->objectID and element-<drawPlane (in
  153.     addition to those initialized by the GraphicLoadFunc).
  154.     
  155.     It is normally called only from a higher-level creation function.
  156. */
  157.  
  158. GrafElPtr NewGrafElement(GEWorldPtr world, OSType id, short plane, short elemSize,
  159.                             GraphicLoadFunc loadProc, short resStart, short nRsrcs);
  160.                             
  161. /*
  162.     Unlinks a graphic element from its world and disposes of it. Note: if the element is
  163.     part of a higher-level struct, i.e. if fields have been added, the contents of these
  164.     fields must be disposed of before calling DisposeGrafElement.
  165. */
  166.  
  167. void DisposeGrafElement(GEWorldPtr world, OSType objectID);
  168.  
  169. //Access
  170.  
  171. /*
  172.     Returns individual element with ID objectID
  173. */
  174.  
  175. GrafElPtr FindElementByID(GEWorldPtr world, OSType objectID);
  176.  
  177. /*
  178.     Returns first element with drawPlane == plane. For collision checking, etc.
  179. */
  180.  
  181. GrafElPtr ElementsInPlane(GEWorldPtr world, short plane);
  182.  
  183. //Control
  184.  
  185. /*
  186.     ShowElement shows or hides a graphic element, depending on the value of showIt
  187. */
  188.  
  189. void ShowElement(GEWorldPtr world, OSType elementID, Boolean showIt);
  190.  
  191. /*
  192.     Move graphic elements
  193. */
  194.  
  195. void MoveElement(GEWorldPtr world, OSType elementID, short dh, short dv);
  196. void MoveElementTo(GEWorldPtr world, OSType elementID, short h, short v);
  197.  
  198. //Alternate interface: avoid lookup when GrafElPtr already available, for example
  199. //in Autochange procedures
  200.  
  201. void PtrMoveElement(GEWorldPtr world, GrafElPtr element, short dh, short dv);
  202. void PtrMoveElementTo(GEWorldPtr world, GrafElPtr element, short h, short v);
  203.  
  204. /*
  205.     Sets element's plane to newPlane
  206. */
  207.  
  208. void SetElementPlane(GEWorldPtr world, OSType elementID, short newPlane);
  209.  
  210. /*
  211.     Set element's autochange parameters
  212. */
  213.  
  214. void SetAutoChange(GEWorldPtr world, OSType elementID, AutoChangeProc changeProc,
  215.                         Ptr changeData, short changeIntrvl);
  216.                         
  217. /*
  218.     Set element's collision parameters. No collision if collisionPlane == 0
  219. */
  220.  
  221. void SetCollision(GEWorldPtr world, OSType elementID, CollisionProc collideProc, 
  222.                         short collidePlane);
  223.  
  224. //Miscellaneous sensor services
  225.  
  226. //Add sensor to world's sensor list and make it active
  227. void AddSensorToList(GEWorldPtr world, OSType id, Rect *sensorRect);
  228.  
  229. //Remove sensor from world's sensor list and make it inactive
  230. void RemoveSensorFromList(GEWorldPtr world, OSType id);
  231.  
  232. //Set sensor's actionProc to newAction
  233. void SetSensorAction(GEWorldPtr world, OSType sensorID, SensorAction newAction);
  234.  
  235. //Get element's entry in world->sensorList, if any
  236. SListEntryPtr FindSensorListEntry(GEWorldPtr world, OSType sensorID);
  237.  
  238. /*
  239.     If anything in a world is changed from OUTSIDE the Graphic Elements system,
  240.     call this procedure with the affected rectangle.
  241. */
  242.  
  243. void ChangedRect(GEWorldPtr world, Rect *chgdRect);
  244.  
  245.  
  246. /*
  247.     GraphicLoadFunc which:
  248.     
  249.     1)    Searches to see if the required graphics are already available in this world, 
  250.         and copies their parameters if so,
  251.     2)     Otherwise, creates a new offscreen GWorld of an appropriate size, and
  252.         loads nResources PICTs from an open resource file into it, starting
  253.         at the PICT with resource number startResNum
  254.         
  255.     This is the default loaderFunc of a newly created GEWorld.
  256. */
  257.  
  258. pascal Boolean LoadPICTElement(GEWorldPtr world, GrafElPtr element,
  259.                                         short startResNum, short nResources);
  260.  
  261.  
  262. /*
  263.     GraphicLoadFunc which does nothing except initialize the appropriate fields.
  264.     For Graphic Elements which have no permanent offscreen representations, e.g.
  265.     strings or fills.
  266. */
  267.  
  268. pascal Boolean NoLoader(GEWorldPtr world, GrafElPtr element,
  269.                                         short startResNum, short nResources);
  270.  
  271.  
  272.  
  273. #ifdef __cplusplus
  274. }
  275. #endif
  276.  
  277.  
  278. #endif